# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2022年01月03日
"""
from lxml import etree

tree = etree.parse('b.html')
# result=tree.xpath('/html')
# result=tree.xpath('/html/body/ul/li/a/text()')
# result=tree.xpath('/html/body/ul/li[1]/a/text()') #xpath的顺序是从1开始的
# result = tree.xpath("/html/body/ol/li/a[@href='dapao']/text()")
ol_li_list = tree.xpath("/html/body/ol/li")

for li in ol_li_list:
	# print(li.xpath("./a/text()"))
	result = li.xpath("./a/@href") # 拿到属性值
	print(result)
# print(ol_li_list)
print(tree.xpath('/html/body/div[1]'))


